import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import App from './App.vue'
import Home from './views/Home.vue'
import TutorAssistant from './views/TutorAssistant.vue'
import './style.css'

// 引入 DevUI 组件库和样式
import DevUI from 'vue-devui'
import 'vue-devui/style.css'
// 注意：图标样式已通过自定义 Icon 组件实现，无需导入 @devui-design/icons 的 CSS

// 引入主题服务
import { ThemeServiceInit, infinityTheme } from 'devui-theme'

// 初始化主题
ThemeServiceInit({ infinityTheme }, 'infinityTheme')

// 引入全局配置
import globalConfig from './config/global-config'

// 使用 CSS 变量设置自定义主题
if (typeof document !== 'undefined') {
  const root = document.documentElement
  Object.entries(globalConfig.customTokens).forEach(([key, value]) => {
    root.style.setProperty(key, value as string)
  })
}

const routes = [
  { path: '/', component: Home },
  { path: '/tutor', component: TutorAssistant }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

const app = createApp(App)
app.use(DevUI)
app.use(router)
app.mount('#app')
